from time import sleep
import uiautomation
import pyautogui


class   Zhongyaochufang():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    zhongyaochufang = his.TabControl(AutomationId='tabZhenliao', ClassName='TabControl').TabItemControl(Name='中药处方',ClassName='TabItem')  # 中药处方
# 中药处方
    yaopinmingcheng1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 1',ClassName="DataGridCell", foundIndex=1)
    yaopinmingcheng1_1 = yaopinmingcheng1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 中药药品名称输入框

    yaopinmingcheng2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 1',ClassName="DataGridCell", foundIndex=2)
    yaopinmingcheng2_1 = yaopinmingcheng2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 中药药品名称输入框

    yaopinmingcheng3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 1',ClassName="DataGridCell", foundIndex=3)
    yaopinmingcheng3_1 = yaopinmingcheng3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 中药药品名称输入框

    yaopinmingcheng4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 1',ClassName="DataGridCell", foundIndex=4)
    yaopinmingcheng4_1 = yaopinmingcheng4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 中药药品名称输入框

    yaopinmingcheng5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 1',ClassName="DataGridCell", foundIndex=5)
    yaopinmingcheng5_1 = yaopinmingcheng5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 中药药品名称输入框

#煎法
    jianfa1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 4',ClassName="DataGridCell",foundIndex=1)
    jianfa1_1 = jianfa1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 煎法输入框
    jianfa2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 4',ClassName="DataGridCell",foundIndex=2)
    jianfa2_1 = jianfa2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 煎法输入框
    jianfa3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 4',ClassName="DataGridCell",foundIndex=3)
    jianfa3_1 = jianfa3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 煎法输入框
    jianfa4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 4',ClassName="DataGridCell",foundIndex=4)
    jianfa4_1 = jianfa4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 煎法输入框
    jianfa5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 4',ClassName="DataGridCell",foundIndex=5)
    jianfa5_1 = jianfa5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 煎法输入框




#次数

    cishu1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 7',ClassName="DataGridCell",foundIndex=1)
    cishu1_1 = cishu1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框
    cishu2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 7',ClassName="DataGridCell",foundIndex=2)
    cishu2_1 = cishu2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框
    cishu3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 7',ClassName="DataGridCell",foundIndex=3)
    cishu3_1 = cishu3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框
    cishu4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 7',ClassName="DataGridCell",foundIndex=4)
    cishu4_1 = cishu4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框
    cishu5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 7',ClassName="DataGridCell",foundIndex=5)
    cishu5_1 = cishu5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 次数输入框

#用法



    yongfa1 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=1)
    yongfa1_1 = yongfa1.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框
    yongfa2 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=2)
    yongfa2_1 = yongfa2.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框
    yongfa3 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=3)
    yongfa3_1 = yongfa3.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框
    yongfa4 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=4)
    yongfa4_1 = yongfa4.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框
    yongfa5 = his.CustomControl(Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.MZCF.MenZhenChuFangModelBase，列显示索引: 6',ClassName="DataGridCell",foundIndex=5)
    yongfa5_1 = yongfa5.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')  # 用法输入框



#点击中药处方
    def click_zycf_btn(self):
        self.zhongyaochufang.DoubleClick()
        sleep(0.5)
#中药处方
    #输入药品名称
    def input_zy_ypmc1(self,ypmc):
        self.yaopinmingcheng1.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng1_1.SendKeys(ypmc)
        pyautogui.press('enter')
    def input_zy_ypmc2(self,ypmc):
        self.yaopinmingcheng2.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng2_1.SendKeys(ypmc)
        pyautogui.press('enter')
    def input_zy_ypmc3(self,ypmc):
        self.yaopinmingcheng3.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng3_1.SendKeys(ypmc)
        pyautogui.press('enter')
    def input_zy_ypmc4(self,ypmc):
        self.yaopinmingcheng4.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng4_1.SendKeys(ypmc)
        pyautogui.press('enter')
    def input_zy_ypmc5(self,ypmc):
        self.yaopinmingcheng5.DoubleClick()
        sleep(0.5)
        self.yaopinmingcheng5_1.SendKeys(ypmc)
        pyautogui.press('enter')



    #选择煎法
    def choose_zy_jf1(self,jf):
        self.jianfa1.DoubleClick()
        self.jianfa1_1.SendKeys(jf)
        pyautogui.press('enter')

    def choose_zy_jf2(self,jf):
        self.jianfa2.DoubleClick()
        self.jianfa2_1.SendKeys(jf)
        pyautogui.press('enter')


    def choose_zy_jf3(self,jf):
        self.jianfa3.DoubleClick()
        self.jianfa3_1.SendKeys(jf)
        pyautogui.press('enter')


    def choose_zy_jf4(self,jf):
        self.jianfa4.DoubleClick()
        self.jianfa4_1.SendKeys(jf)
        pyautogui.press('enter')


    def choose_zy_jf5(self,jf):
        self.jianfa5.DoubleClick()
        self.jianfa5_1.SendKeys(jf)
        pyautogui.press('enter')




    #选择次数
    def choose_zy_cs1(self,cs):
        self.cishu1.DoubleClick()
        self.cishu1_1.SendKeys(cs)
        pyautogui.press('enter')

    def choose_zy_cs2(self,cs):
        self.cishu2.DoubleClick()
        self.cishu2_1.SendKeys(cs)
        pyautogui.press('enter')

    def choose_zy_cs3(self,cs):
        self.cishu3.DoubleClick()
        self.cishu3_1.SendKeys(cs)
        pyautogui.press('enter')

    def choose_zy_cs4(self,cs):
        self.cishu4.DoubleClick()
        self.cishu4_1.SendKeys(cs)
        pyautogui.press('enter')

    def choose_zy_cs5(self,cs):
        self.cishu5.DoubleClick()
        self.cishu5_1.SendKeys(cs)
        pyautogui.press('enter')




    #选择用法
    def choose_zy_yf1(self,yf):
        self.yongfa1.DoubleClick()
        self.yongfa1_1.SendKeys(yf)
        pyautogui.press('enter')

    def choose_zy_yf2(self,yf):
        self.yongfa2.DoubleClick()
        self.yongfa2_1.SendKeys(yf)
        pyautogui.press('enter')

    def choose_zy_yf3(self,yf):
        self.yongfa3.DoubleClick()
        self.yongfa3_1.SendKeys(yf)
        pyautogui.press('enter')

    def choose_zy_yf4(self,yf):
        self.yongfa4.DoubleClick()
        self.yongfa4_1.SendKeys(yf)
        pyautogui.press('enter')

    def choose_zy_yf5(self,yf):
        self.yongfa5.DoubleClick()
        self.yongfa5_1.SendKeys(yf)
        pyautogui.press('enter')

#第一排数据
    def input_zy1(self,ypmc,jf,yf,cs):
        self.input_zy_ypmc1(ypmc)
        self.choose_zy_jf1(jf)
        self.choose_zy_yf1(yf)
        self.choose_zy_cs1(cs)

#第二排数据
    def input_zy2(self, ypmc, jf, yf, cs):
        self.input_zy_ypmc2(ypmc)
        self.choose_zy_jf2(jf)
        self.choose_zy_yf2(yf)
        self.choose_zy_cs2(cs)

    #第三排数据
    def input_zy3(self, ypmc, jf, yf, cs):
        self.input_zy_ypmc3(ypmc)
        self.choose_zy_jf3(jf)
        self.choose_zy_yf3(yf)
        self.choose_zy_cs3(cs)

    #第四排数据
    def input_zy4(self, ypmc, jf, yf, cs):
        self.input_zy_ypmc4(ypmc)
        self.choose_zy_jf4(jf)
        self.choose_zy_yf4(yf)
        self.choose_zy_cs4(cs)

    #第五排数据
    def input_zy5(self, ypmc, jf, yf, cs):
        self.input_zy_ypmc5(ypmc)
        self.choose_zy_jf5(jf)
        self.choose_zy_yf5(yf)
        self.choose_zy_cs5(cs)



